package com.xxl.job.executor.common.util;

import java.util.HashMap;
import java.util.Map;

public class Constants {

	public static enum SystemId{

		TB("8","结算系统"),ETC("10","ETC运营中心"),BC("11","部中心");

		private SystemId(String value,String name){
			this.value = value;
			this.name = name;
		}
		private final String value;
		private final String name;

		public String getValue() {
			return value;
		}

		public String getName() {
			return name;
		}

	}

	/**
	 * 处理结果
	 *
	 */
    public static enum Dealresult{
        
        FAIL(0,"失败"),SUCCESS(1,"成功"),PARTSUCCESS(2,"部分成功");
        
        private Dealresult(Integer value,String name){
            this.value = value;
            this.name = name;
        }
        private final Integer value;
        private final String name;
        
        public Integer getValue() {
            return value;
        }

        public String getName() {
            return name;
        }
        
    }


	/**
	 * 站/门架 -- 》 省上传异常
	 *
	 */
	public static enum UploadException{
		CENTERVALIDATE_EXCEPTION((short)1,"数据中台校验失败"),
		BIZVALIDATE_EXCEPTION((short)2,"业务系统校验失败"),
		OTHER_EXCEPTION((short)3,"其他失败");

		private UploadException(Short value,String name){
			this.value = value;
			this.name = name;
		}
		private final Short value;
		private final String name;

		public Short getValue() {
			return value;
		}

		public String getName() {
			return name;
		}

		public static String getNameByValue(Short value) {
			for(UploadException uploadException : UploadException.values()){
				if(uploadException.getValue().shortValue()==value.shortValue()){
					return uploadException.getName();
				}
			}
			return "";
		}

	}
    
	/**
	 * 汇聚处理异常
	 *
	 */
	public static enum DealException{
		HTTPSEND_SUCCESS(200,"HTTP请求成功"),
		RECEIVE_SUCCESS(200,"站或门架接收数据成功"),
		CONVERT_EXCEPTION(1,"json转entity失败"),//入成功表时
		INSERTTABLE_EXCEPTION(2,"入库异常"),//入成功表时
		HTTPSEND_EXCEPTION(3,"HTTP推送响应异常"),
		KAFKASEND_EXCEPTION(4,"KAFKA推送响应异常"),


		FAIL_CONVERT_EXCEPTION(5,"json转entity失败"),//入失败表时
		FAIL_INSERTTABLE_EXCEPTION(6,"入库异常"),//入失败表时

		ALL_CONVERT_EXCEPTION(7,"json转entity失败"),//入全表时
		ALL_INSERTTABLE_EXCEPTION(8,"入库异常");//入全表时
		//9  被占用

		private DealException(Integer value,String name){
			this.value = value;
			this.name = name;
		}
		private final Integer value;
		private final String name;

		public Integer getValue() {
			return value;
		}

		public String getName() {
			return name;
		}

		public static String getNameByValue(Integer value) {
			for(DealException dealException : DealException.values()){
				if(dealException.getValue().intValue()==value.intValue()){
					return dealException.getName();
				}
			}
			return "";
		}

	}
    
    /**
     * 上传结果错误类型
     *
     */
    public static enum ErrorType{
    	
    	SUCCESS(1,"处理成功"),
    	VALIDATE_ERR(2,"金额或者条数校验失败"),
    	BUSSINESS_ERR(3,"业务校验失败"),
    	DATACENTERIMG_ERR(4,"从数据中台获取图片失败"),
    	RESPONSENULL_ERR(7,"服务器成功处理了请求，但没有返回任何内容"),
    	HTTPOUT_ERR(8,"连接超时"),
    	DATA_ERR(9,"数据解析有误"),
    	BATCHNOREPEAT_ERR(10,"批次号重复"),
    	ENCODING_ERR(11,"指定的编码集不对"),
    	CLIENT_ERR(12,"客户端异常"),
    	IO_ERR(13,"IO异常"),
    	COMM_ERR(14,"通讯未知系统异常"),
    	NOTFILE_ERR(15,"获取不到响应的文件名"),
    	SOCKET_ERR(16,"SocketTimeoutException异常");
    	
    	private ErrorType(Integer value,String desc){
    		this.value = value;
    		this.desc = desc;
    	}
    	private final Integer value;
    	private final String desc;
    	
    	public Integer getValue() {
    		return value;
    	}
    	
    	public String getDesc() {
    		return desc;
    	}
    	
    }

	public static enum ArrayMsg{
		JSON_STRING(0,"单对象消息"),JSON_FILE(1,"数据对象消息"),MULTI_FILE(2,"符合数据对象消息");

		private ArrayMsg(Integer value,String name){
			this.value = value;
			this.name = name;
		}
		private final Integer value;
		private final String name;

		public Integer getValue() {
			return value;
		}

		public String getName() {
			return name;
		}

	}
    
    /**
     * 批次号校验，redis key
     *
     */
    public interface  RedisKey{
		public static final String MSG_TYPE_KEY = "msgtype";//消息类型【接口类型（标识唯一）_命令】
		public static final String DISTRIBUTE_CFG_KEY = "distributecfg";//消息类型【接口类型（标识唯一）_命令】
    	public static final String RESEND_THREETIMES_KEY = "resendThree";//重发列表
    	public static final String CARD_UPLOAD_KEY = "cardlist_{0}";//卡状态变更队列
    	public static final String OBU_UPLOAD_KEY = "obulist_{0}";//OBU状态变更队列
    }

    /**
     * topic
     *
     */
    public interface  Topic{
		String COLLECTLOG_TOPIC = "collectlogtopic";
		String UPLOADEXCEPTION_TOPIC = "uploadexceptiontopic";
		String UPLOADNODEALEXCEPTION_TOPIC = "uploadnodealexceptiontopic";
    	String DEALDATAEXCEPTION_TOPIC = "dealdataexceptiontopic";
    	String STATISSENDCLEAR_TOPIC = "statissendcleartopic";
    }


	/**
	 * 流水统计-流水类型
	 * 101-入口流水记录
	 * 102-出口流水记录
	 * 103-ETC入口流水记
	 * 104-ETC出口流水记录
	 * 113-ETC门架计费扣费交易
	 */
	public static enum OperType{

		OPER_TYPE_101("101","BASIC_BINLIST","入口流水记录"),
		OPER_TYPE_102("102","BASIC_BOUTLIST","出口流水记录"),
		OPER_TYPE_103("103","BASIC_ETCBINLIST","ETC入口流水记录"),
		OPER_TYPE_104("104","BASIC_ETCBOUTLIST","ETC出口流水记录"),
		OPER_TYPE_112("112","GBUPLOAD_ETCTU","真实门架计费扣费交易"),
		OPER_TYPE_113("113","BASIC_GRANTRYTRANSMAIN","承载门架计费扣费交易"),
		OPER_TYPE_114("114","","出口站 ETC 交易数据上传（本省本地）"),
		OPER_TYPE_115("115","","记账交易下载（本省本地）");

		OperType(String type,String filename, String desc){
			this.value = type;
			this.filename = filename;
			this.desc = desc;
		}
		private final String value;
		private final String filename;
		private final String desc;

		public String getValue() {
			return value;
		}
		public String getFilename() {
			return filename;
		}

		public String getDesc() {
			return desc;
		}

	}

    
    /**
     * 批次号校验，redis key
     *
     */
    public interface  TimeSeconds{
    	public static final int ONE_SECOND = 1;
    	public static final int FIVE_SECOND = 5;
    	public static final int THIRTY_SECOND = 30;
    	public static final int ONE_MINUTE = 60;
    	public static final int FIFTEEN_MINUTE = 900;
    	public static final int ONE_HOUR = 60*60;
    	public static final int ONE_DAY = 60*60*24;
    	public static final int THREE_DAY = 60*60*24*3;
    	public static final int SEVEN_DAY = 60*60*24*7;
    	
    }

    public static Map<String,Short> toDealMap = new HashMap<String,Short>(){
		{
			put("BASIC_BINLIST",(short)2);
			put("BASIC_ETCBINLIST",(short)2);
			put("BASIC_ETCBOUTLIST",(short)2);
			put("BASIC_BOUTLIST",(short)2);
			put("BASIC_GRANTRYTRANSMAIN",(short)2);
			put("GBUPLOAD_ETCTU",(short)2);

		}
	};
    
    
}
